package com.securitydemo.enums;

import java.util.Objects;
import java.util.stream.Stream;

/**
 * 数据状态
 */
public enum DataStatus {
    /**
     * 正常数据
     */
    NORMAL(1),
    /**
     * 软删除状态
     */
    DELETE(0);

    private int code;

    private DataStatus(int code) {
        this.code = code;
    }

    public int getCode() {
        return code;
    }

    public static DataStatus of(int code) {
        return Stream.of(DataStatus.values()).filter(d -> Objects.equals(code, d.getCode())).findFirst().orElseThrow(IllegalAccessError::new);
    }
}
